<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp"%>
<script type="text/javascript" src="${ctxStatic}/js/jquery.validate.min.js"></script>
<title>合同二审详情</title>
<style type="text/css">
.button {
	width: 100px;
	height: 30px;
	margin: 3px 20px 3px 0;
	padding-top: 3px;
}

* {
	font-size: 14px;
}

.th td {
	font-weight: 700;
}
/* label{margin: 0 10px 0 18px;font-weight: 500;height: 25px;line-height: 25px;} */
.control-label {
	padding: 0;
	font-weight: bold;
}

.diaform {
	margin: 20px auto;
}

h3 {
	border-bottom: 1px solid #ddd;
	padding-bottom: 5px;
	width: 98%;
}

.datagrid-view {
	border-top: 1px solid #ddd;
	margin-top: 8px;
}

.datagrid-pager {
	border-bottom: 1px solid #ccc;
}

hr {
	margin: 15px 0 13px 0;
	background-color: #ddd;
	height: 1px;
	border: 0;
	width: 120%;
}

.jianju {
	margin-left: 15px;
}

.datagrid-htable {
	font-weight: bold;
	/* background-color: #148CCA; */
}

.demo_line_01 {
	margin: 5px 0;
	font-size: 50px;
	line-height: 1px;
	text-align: center;
}

.demo_line_01 .line {
	display: inline-block;
	width: 47.8%;
	height: 1px;
	background: #ddd;
	vertical-align: middle;
	margin-top: 8px;
}

.container-fluid {
	padding-left: 15px;
}

.datagrid-ftable td div {
	font-size: larger;
}

#pulldown {
	margin-top: 20px;
}

/* td.datagrid-header-over{
	background: #148CCA !important;
} */
</style>
<title>合同二审详情</title>
<style>
.datagrid-body {
	height: 320px !important;
}

.datagrid-view {
	height: 350px !important;
}
</style>
<script type="text/javascript">
	$(function() {
		
		contractExe.init();
		
		$("#back").click(function(){
			location.href = "${pageContext.request.contextPath}/secContract";
		})
		
		
	});
	
	//创建对象
	var contractExe = {}

	contractExe.init = function() {
		// 初始化表单校验
		contractExe.initValidate();
	}
	contractExe.submitAdd = function(data) {
		var flag = true;
		
		if(data == 1){
			$("#status").val("1")
			$("#fm").submit();
		}else if(data == 0){
			$("#status").val("0")
			var reason = $("#secInsReason").val();
			if(reason == null || reason == ""){
				flag = false;
				error.innerHTML = "请输入拒绝理由在拒绝";
			}
		}
		
		if(flag){
		$("#fm").submit();
		}
		
	}
	
	
	
	jQuery.validator.addMethod("isMobile", function(value, element) {  
	    var length = value.length;  
	    var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;  
	    return this.optional(element) || (length == 11 && mobile.test(value));  
	}, "请正确填写您的手机号码");  
	/**
	 * 初始化表单校验
	 */
	contractExe.initValidate = function() {// jQuery Validate
		$("#fm").validate({
			rules : {
				approvalAmount : {
					required : true,
					number:true,
				},
				approvalCyc : {
					required : true,
					number:true,
					rangelength:[1,3],
				}
			},
			messages : {  
				approvalAmount : {
						required: "必须要输入",
						  number: "请输入数字",
					},
					approvalCyc : {
						required: "必须要输入",
						  number: "请输入数字",
						rangelength:"最小输入二位数字，最大三位",
					}
				  },
			submitHandler : function(form) {// 校验通过后执行
				contractExe.submitAddForm(form);
				return false;
			}
		});
	}

	contractExe.submitAddForm = function(form) {
		var url = "refuseOrAgree";
		var form =new FormData(document.getElementById("fm"));  
		$.ajax({
			url : url,
			method : "post",
			data : form,
			 async: true,  
	         cache: false,  
			processData : false,
			contentType : false,
			success : function(data) {// 获取查询结果客户集合
				location.href = "${pageContext.request.contextPath}/secContract";
			}
		});
	}

	function rowStyle(index, row) {
		if (index % 2 == 0) {
			return 'background-color:lightcyan;';
		}
	}
</script>
</head>
<body>

	<div class="jianju">
		<h3>合同二审详情</h3>
		<div id="tb" style="height: auto">
			<a id="agree" href="#" class="easyui-linkbutton button"
				style="margin-left: 15px;" iconCls="icon-search" onclick="contractExe.submitAdd(1)">同意</a> <a
				id="refuse" href="#" class="easyui-linkbutton button"
				style="margin-left: 15px;" iconCls="icon-search" onclick="contractExe.submitAdd(0)">拒绝</a>
				<a id="back" href="#" class="easyui-linkbutton button"
				style="margin-left: 15px;" iconCls="icon-search">返回</a> 
		</div>
	</div>
		
		<label style="margin-left: 15px">手机号码：</label>
		<input id="cellPhone" class="easyui-textbox" style="width: 200px" value="${firContractExe.cellPhone }" readonly="readonly">
		 <label style="margin-left: 15px">客户姓名：</label>
		 <input id="customerName" class="easyui-textbox" style="width: 200px" value="${firContractExe.customerName }" readonly="readonly"><br>
		 <label style="margin-left: 15px">户口所在地：</label>
		 <input id="residenceAddress" class="easyui-textbox" style="width: 800px" value="${firContractExe.residenceAddress }" readonly="readonly" ><br>
		 <label style="margin-left: 15px">履约地址：</label>
		 <input id="agreeAddress" class="easyui-textbox" style="width: 800px"value="${firContractExe.agreeAddress }"  readonly="readonly"><br>
		 <label style="margin-left: 15px">身份证：</label>
		 <input id="card" class="easyui-textbox" style="width: 200px" value="${firContractExe.card }" readonly="readonly">
		 <label style="margin-left: 15px">紧急联系方式：</label>
		 <input id="emerContact" class="easyui-textbox" style="width: 200px" value="${firContractExe.emerContact }" readonly="readonly"><br>
		 <label style="margin-left: 15px">籍贯：</label>
		 <input id="origin" class="easyui-textbox" style="width: 200px" value="${firContractExe.origin }" readonly="readonly">
		 <label style="margin-left: 15px">婚姻状况：</label>
		 <input id="marriage" class="easyui-textbox" style="width: 200px" value="${firContractExe.marriage }" readonly="readonly"><br>
		 <label style="margin-left: 15px">性别：</label>
		 <input id="SEX" class="easyui-textbox" style="width: 200px" value="${firContractExe.sex }" readonly="readonly">
		 <label style="margin-left: 15px">服务费率：</label>
		 <input id="serFee" class="easyui-textbox" style="width: 200px" value="${firContractExe.serFee }" readonly="readonly"><br>
		 <label style="margin-left: 15px">用途：</label>
		 <input id="usageq" class="easyui-textbox" style="width: 800px" value="${firContractExe.usageq }" readonly="readonly"><br>
		 <label style="margin-left: 15px">拟借金额：</label>
		 <input id="expAmount" class="easyui-textbox" style="width: 200px" value="${firContractExe.expAmount }" readonly="readonly">(元)
		 <label style="margin-left: 15px">拟借款期数：</label>
		 <input id="expCyc" class="easyui-textbox" style="width: 200px" value="${firContractExe.expCyc }" readonly="readonly"><br>
		 <label style="margin-left: 15px">拟借款日期：</label>
		 <input id="expDate" class="easyui-textbox" style="width: 200px" value="${firContractExe.expDate }"><br>
		 <label style="margin-left: 15px">身份证：</label>
         <input id="photoOfIdCard" class="easyui-textbox" style="width: 80px" ><br>
		 <label style="margin-left: 15px">履行合同：</label>
		 <input id="lvyueContract" class="easyui-textbox" style="width: 80px"><br>
		 <label style="margin-left: 15px">其它附件：</label>
		 <input id="qitaContract" class="easyui-textbox" style="width: 80px"><br>
		 <label style="margin-left: 15px">合同备注：</label>
		 <textarea id="memo"  style="width: 80%"  >${firContractExe.memo } </textarea><br>
		 <label style="margin-left: 15px">建议金额：</label>
		 <input id="adviseAmount" name="adviseAmount"  style="width: 200px" value="${firContractExe.adviseAmount }" required="required">
		 <label style="margin-left: 15px">建议期数：</label>
		 <input id="adviseCyc" name="adviseCyc" style="width: 200px" value="${firContractExe.adviseCyc }" required="required"><br>
		 <label style="margin-left: 15px">推荐人：</label>
		 <input id="recom" name="recom"  style="width: 200px" value="${firContractExe.recom }" required="required">
		<label style="margin-left: 15px">推荐人联系电话：</label>
		  <input id="recomPhone" name="recomPhone"  style="width: 200px" value="${firContractExe.recomPhone }" required="required"><br>
		
		<form id="fm" method="post" class="form-horizontal" role="form">
		<!--合同id  -->
		<input id="id" type="hidden" name="id" value="${firContractExe.id}"> 
		<!-- 判断是拒绝还是同意 -->
		<input id="status" type="hidden" name ="status" > 
		 <span style="color: red">*</span><label style="margin-left: 15px">审批金额：</label>
		 <input id="approvalAmount" name="approvalAmount"  style="width: 200px" value="${firContractExe.approvalAmount }" required="required">
		 <span style="color: red">*</span><label style="margin-left: 15px">审批期数：</label>
		 <input id="approvalCyc" name="approvalCyc"  style="width: 200px" value="${firContractExe.approvalCyc }" required="required"><br>
		 
		 <label style="margin-left: 15px">拒绝理由：</label>
		 <textarea id="secInsReason"  name="secInsReason" style="width: 80%" >${firContractExe.secInsReason }</textarea><br>
		<span id="error" style="color: red "></span>
	</form>


</body>

</html>